<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 4. 对数组，按照价格进行升序排序
    const arr4 = [
        { id: 1, name: '茶杯', price: 18 },
        { id: 2, name: '电视机', price: 2000 },
        { id: 3, name: '牙刷', price: 8 },
        { id: 4, name: '电脑', price: 5000 },
      ]
      console.log(arr4.sort((a,b)=>a.price -b.price));
  </script>
</body>
</html>